package com.guanlixitong.domain;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.Period;
import java.util.ArrayList;

public class Student implements Serializable {
    private static final  long serialVersionUID = 20221221949L;

    //private String xulie;
    private String id;
    private String name;
    private String sex;
    private int age;
    private LocalDate birthday;
    private int  group;
    private String subject;
    private String phone;
    private ArrayList<String> list;

    public Student() {
    }

    public Student(String id, String name, String sex, int age, LocalDate birthday, int group, String subject, String phone, ArrayList<String> list) {
        this.id = id;
        this.name = name;
        this.sex = sex;
        this.birthday = birthday;
        setAge();
        this.group = group;
        this.subject = subject;
        this.phone = phone;
        this.list = list;
    }


    public String getId() {
        return id;
    }


    public void setId(String id) {
        this.id = id;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getSex() {
        return sex;
    }


    public void setSex(String sex) {
        this.sex = sex;
    }


    public int getAge() {
        return age;
    }


    public void setAge() {
        age = Period.between(birthday,LocalDate.now()).getYears();
    }


    public LocalDate getBirthday() {
        return birthday;
    }


    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
        setAge();
    }


    public int getGroup() {
        return group;
    }


    public void setGroup(int group) {
        this.group = group;
    }


    public String getSubject() {
        return subject;
    }


    public void setSubject(String subject) {
        this.subject = subject;
    }


    public String getPhone() {
        return phone;
    }


    public void setPhone(String phone) {
        this.phone = phone;
    }


    public ArrayList<String> getList() {
        return list;
    }


    public void setList(ArrayList<String> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", group=" + group +
                ", subject='" + subject + '\'' +
                ", phone='" + phone + '\'' +
                ", list=" + list +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student student = (Student) o;

        if (age != student.age) return false;
        if (group != student.group) return false;
        if (id != null ? !id.equals(student.id) : student.id != null) return false;
        if (name != null ? !name.equals(student.name) : student.name != null) return false;
        if (sex != null ? !sex.equals(student.sex) : student.sex != null) return false;
        if (birthday != null ? !birthday.equals(student.birthday) : student.birthday != null) return false;
        if (subject != null ? !subject.equals(student.subject) : student.subject != null) return false;
        if (phone != null ? !phone.equals(student.phone) : student.phone != null) return false;
        return list != null ? list.equals(student.list) : student.list == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (sex != null ? sex.hashCode() : 0);
        result = 31 * result + age;
        result = 31 * result + (birthday != null ? birthday.hashCode() : 0);
        result = 31 * result + group;
        result = 31 * result + (subject != null ? subject.hashCode() : 0);
        result = 31 * result + (phone != null ? phone.hashCode() : 0);
        result = 31 * result + (list != null ? list.hashCode() : 0);
        return result;
    }
}

